/**
 * @author gao
 * @date 2025/6/30 10:26
 */

public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        // 创建了Thread对象，还没启动
        System.out.println(t.getState() + " isAlive: " + t.isAlive());
        t.start();
        System.out.println(t.getState() + " isAlive: " + t.isAlive());
        t.join();
        // 线程执行完了，但Thread对象还在
        System.out.println(t.getState() + " isAlive: " + t.isAlive());
    }
}